home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / net / bind-contrib.tar.gz / bind-contrib.tar / contrib / misc / nscount.mime < prev    next >
Encoding:
Internet Message Format  |  1996-10-25  |  3.4 KB

  1. Path: vixie!news1.digital.com!nntp-hub2.barrnet.net!hookup!news.mathworks.com!gatech!news.sprintlink.net!demon!doc.news.pipex.net!pipex!sunic!sunic.sunet.se!umdac!fizban.solace.mh.se!vampire.xinit.se!newsfeed.tip.net!snoop.uni.net!newsmaster
  2. From: Paolo Bevilacqua <pab@rmnet.it>
  3. Newsgroups: comp.protocols.tcp-ip.domains
  4. Subject: nscount - A small DNS tool.
  5. Date: 21 May 1995 19:00:53 GMT
  6. Organization: RMnet Communications
  7. Lines: 97
  8. Distribution: inet
  9. Message-ID: <3po2l5$ri5@snoop.uni.net>
  10. NNTP-Posting-Host: malcolm.rmnet.it
  11. Mime-Version: 1.0
  12. Content-Type: multipart/mixed;
  13.     boundary="-------------------------------183241065221292338711929778377"
  14. X-Mailer: Mozilla 1.1N (X11; I; Linux 1.2.8 i486)
  15. X-URL: file:/root/nscount
  16.  
  17. This is a multi-part message in MIME format.
  18.  
  19. ---------------------------------183241065221292338711929778377
  20. Content-Transfer-Encoding: 7bit
  21. Content-Type: text/plain; charset=us-ascii
  22.  
  23. Hello.
  24.  
  25. Because a similar tool is missing from the contrib stuff in the standard BIND
  26. distribution, I wrote it, and because it's short, here it is.
  27. Basically, it tells you what are the nameservers servicing more domains under a
  28. given domain - realistically, a TLD.
  29.  
  30. -- 
  31. # RMnet Communications   *********    Via Taro 56 #
  32. # Paolo Bevilacqua    *****   00199 - Rome, Italy #
  33. # Service Manager   ****  Ph/Fax:  +39 6 85302737 #
  34. # The Finest Internet Access  http://www.rmnet.it #
  35.  
  36. ---------------------------------183241065221292338711929778377
  37. Content-Transfer-Encoding: 7bit
  38. Content-Type: text/plain
  39.  
  40. #! /usr/local/bin/perl -w
  41. #  
  42. # Perl script to count how many domains are served by nameservers.
  43. #
  44. # Options:
  45. # -f file           Examine a file output from 'nslookup' or 'host'.
  46. # -s server domain  Runs 'host', asking server to list NS records for domain.
  47. # -c count          Prints count nameservers, 10 by default. Use 0 to print all.
  48. # -v                Verbosely list domains served by each nameserver.
  49. #
  50. #                   May 95 by Paolo Bevilacqua <pab@uni.net>
  51.  
  52. require ("open2.pl");
  53. require ("getopts.pl");
  54.  
  55. Getopts('f:s:c:v');
  56. (defined $opt_f xor defined $opt_s) || die "must use either -f or -s options\n";
  57. (defined $opt_s and $#ARGV != 0) && die "must specify domain for -s option\n";
  58.  
  59. if (defined $opt_f) {
  60.     open(FILE, $opt_f) || die "Can't open $opt_f for reading\n";
  61. } else {
  62.     &open2('FILE', 'NOTUSED', "host -l -t ns $ARGV[0] $opt_s");
  63. }
  64.  
  65. # throw first five lines
  66. for (1..5) {
  67.     <FILE>;
  68. }
  69.  
  70. while(<FILE>) {
  71.     @_ = split;
  72.     (defined $svrs{$_[$#_]}) || push @servers, $_[$#_];
  73.     ++$svrs{$_[$#_]};    
  74.     ++$dmns{$_[0]};
  75.  
  76.     if (defined $opt_v) {
  77.         $_[$#_] =~ tr/-.0-9/a-k/d;
  78.                eval "push(\@$_[$#_], '$_[0]');";
  79.     }
  80. }
  81.  
  82. # sort by number of domains served
  83. @servers = sort{$svrs{$a} < $svrs{$b}} @servers;
  84. @domains = keys %dmns;
  85.  
  86. if (defined $opt_c) {
  87.   $count = $opt_c;
  88. } else {
  89.   $count = 10;
  90. }
  91.  
  92. ($count == 0) && ($count = $#servers);
  93.  
  94. print "$#servers servers, $#domains domains\n";
  95.  
  96. if (defined $opt_v) {
  97.     for ($c = 0; $c < $count; ++$c) {
  98.         print "Domains served by $servers[$c] ($svrs{$servers[$c]}):\n";
  99.         ($arrname = $servers[$c]) =~ tr/-.0-9/a-k/d;
  100.         eval "\@$arrname = sort {\$b cmp \$a} \@$arrname;";
  101.         while ($svrs{$servers[$c]}--) {
  102.             print "   ", eval "pop(\@$arrname);", "\n";
  103.         }
  104.     }
  105. } else {
  106.     print "Top $count name servers for domains:\n";
  107.     for ($i = 0; $i < $count; $i++) {
  108.         printf "%-30.30s%d\n",  $servers[$i], $svrs{$servers[$i]};
  109.     }
  110. }
  111.  
  112.  
  113. ---------------------------------183241065221292338711929778377--
  114.